home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / libcompress-raw-zlib-perl / examples / filtinf < prev   
Encoding:
Text File  |  2008-02-18  |  505 b   |  31 lines

  1. #!/usr/local/bin/perl
  2.  
  3. use Compress::Raw::Zlib ;
  4.  
  5. use strict ;
  6. use warnings ;
  7.  
  8. binmode STDIN;
  9. binmode STDOUT;
  10.  
  11. my $x = new Compress::Raw::Zlib::Inflate
  12.    or die "Cannot create a inflation stream\n" ;
  13.  
  14. my $input = '' ;
  15. my $output = '' ;
  16. my $status ;
  17.  
  18. while (read(STDIN, $input, 4096))
  19. {
  20.     $status = $x->inflate($input, $output) ;
  21.  
  22.     print $output 
  23.         if $status == Z_OK or $status == Z_STREAM_END ;
  24.  
  25.     last if $status != Z_OK ;
  26. }
  27.  
  28. die "inflation failed\n"
  29.     unless $status == Z_STREAM_END ;
  30.  
  31.